package JCT_Chapter_03;
import java.io.IOException;
import java.util.*;

/**
 * This program demonstrates console input
 */

public class InputTest {
    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        //  get first input
        System.out.println("What is your name?");
        String name = in.nextLine();
        //  get second input
        System.out.println("How old are your?");
        int age = in.nextInt();
        //  display output on console
        System.out.println("Hello, " + name + ". Next year, you will be " + (age + 1));
        String message = String.format("Hello, %s. Next year, you will be %d.",name,age+1);
        System.out.println(message);
        System.out.printf("%tc",new Date());
        /**
        //  input username and password
        //只能在输入，输出流未被重定向的原始主控制台中使用
        Console cons = System.console();
        String username = cons.readLine("User name: ");
        char[] passwd = cons.readPassword("Password: ");
    */
    }
}
